package com.cloudptt.wp.ui.address.adapter;

import android.annotation.SuppressLint;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.cloudptt.wp.ui.FragmentInfo;

import java.util.ArrayList;
import java.util.List;

public class MyPagerAdapter extends FragmentPagerAdapter {
    private List<FragmentInfo> fragments = new ArrayList<>();

    @SuppressLint("WrongConstant")
    public MyPagerAdapter(FragmentManager fm,List<FragmentInfo> fragments) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position).getFg();
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return fragments.get(position).getTitle();  // 设置标签标题 :ml-citation{ref="1,3" data="citationList"}
    }
}

